import Bus from '../bus-util';

export const loginSuccess = 'common.loginSuccess';
export const loginExpire = 'common.loginExpire';

const commonModule = {
  loginSuccess: {
    emit: (data) => {
      Bus.$emit(loginSuccess, data);
    },
    on: (cb) => {
      Bus.$on(loginSuccess, cb);
      return () => {
        Bus.$off(loginSuccess, cb);
      };
    }
  },
  loginExpire: {
    emit: () => {
      Bus.$emit(loginExpire);
    },
    on: (cb) => {
      Bus.$on(loginExpire, cb);
      return () => {
        Bus.$off(loginExpire, cb);
      };
    }
  }
};

export default commonModule;
